package summer.codegenerator.model;

import lombok.Getter;
import lombok.Setter;
import summer.codegenerator.model.enumeration.EntityAttributeValueType;
import summer.codegenerator.model.enumeration.EntityAttributeValueTypeConverter;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@javax.persistence.Entity
@Table(name = "entity_attribute")
@Getter
@Setter
public class EntityAttribute {

    @Id
    @GeneratedValue
    @Column(name = "entity_attribute_id")
    private Long entityAttributeId;
    @Column(name = "sq")
    private Integer sq;
    @ManyToOne
    @JoinColumn(name = "related_entity_id")
    private Entity relatedEntity;
    @ManyToOne
    @JoinColumn(name = "attached_entity_id")
    private Entity attachedEntity;
    @Column(name = "entity_attribute_code", nullable = false)
    private String entityAttributeCode;
    @Column(name = "entity_attribute_name", nullable = false)
    private String entityAttributeName;
    @Column(name = "entity_attribute_desc")
    private String entityAttributeDesc;
    @Column(name = "entity_attribute_value_type")
    @Convert(converter = EntityAttributeValueTypeConverter.class)
    private EntityAttributeValueType entityAttributeValueType;
    @Column(name = "entity_attribute_value_auto_increment")
    private Boolean entityAttributeValueAutoIncrement;
    @Column(name = "entity_attribute_value_ci")
    private Boolean entityAttributeValueCi;
    @Column(name = "entity_attribute_value_length_fixed")
    private Boolean entityAttributeValueLengthFixed;
    @Column(name = "entity_attribute_value_length_1")
    private Integer entityAttributeValueLength1;
    @Column(name = "entity_attribute_value_length_2")
    private Integer entityAttributeValueLength2;
}
